package com.example.dibbi.client;

import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.widget.TextView;

public class DibbiMainActivity extends Activity {

	@SuppressLint("NewApi")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dibbi_main);
		TextView txt = (TextView) findViewById(R.id.txtId);
		JSONParser parser = new JSONParser();
		JSONObject json = parser
				.getJSONFromUrl("http://localhost:8888/api/hello");
		
		try {
			String text = json.getString("text");
			txt.setText(text);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.dibbi_main, menu);
		return true;
	}

}
